<!doctype html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
<input type="text" id="input1">
<label for="input1">验证手机号</label>
<button onclick="test1()">验证</button>
<input type="text" id="input2">
<label for="input2">验证连续重复单词</label>
<button onclick="test2()">验证</button>
</body>
<script>
    var test1=function () {
        var reg =/^1[3|4|5|7|8][0-9]{9}$/;
        var phoneNum =document.getElementById("input1").value;
        var flag = reg.test(phoneNum);
        alert(flag);
    };
    var test2=function () {
        var reg=/\b([a-zA-Z]+)\b \1/g;
        var words=document.getElementById("input2").value;
        var flag=reg.test(words);
        alert(flag)
    }

</script>
</html>